package interfacemanagement;

import config.ConfigManager;
import exception.InvalidConfigException;

public class ConfigWindowManager {

	public ConfigWindowManager() {
	}

	public boolean isPaused() {
		boolean isPaused = false;
		try {
			isPaused = ConfigManager.getBooleanConfig("is_paused");
		} catch (InvalidConfigException ex) {
			ex.printStackTrace();
			System.out.println("Config error: " + ex.getMessage());
		}
		return isPaused;
	}

	public boolean isFirstTime() {
		boolean isFirstTime = false;
		try {
			isFirstTime = ConfigManager.getBooleanConfig("is_first_time");
		} catch (InvalidConfigException ex) {
			ex.printStackTrace();
			System.out.println("Config error: " + ex.getMessage());
		}
		return isFirstTime;
	}

	public String getDirectoriesFileName() {
		{
			String directoriesFile = "";
			try {
				directoriesFile = ConfigManager
						.getStringConfig("directories_list_name");
			} catch (InvalidConfigException ex) {
				ex.printStackTrace();
				System.out.println("Config error: " + ex.getMessage());
			}
			return directoriesFile;
		}
	}

	public String getArchivesFileName() {
		String archivesFile = "";
		try {
			archivesFile = ConfigManager.getStringConfig("files_list_name");
		} catch (InvalidConfigException ex) {
			ex.printStackTrace();
			System.out.println("Config error: " + ex.getMessage());
		}
		return archivesFile;
	}

	public String getDefaultDir() {
		String default_dir = "";
		try {
			default_dir = ConfigManager.getStringConfig("default_dir");
		} catch (InvalidConfigException ex) {
			ex.printStackTrace();
			System.out.println("Config error: " + ex.getMessage());
		}
		return default_dir;
	}

	public String getSearchCacheTime() {
		String search_cache_time = "";
		try {
			search_cache_time = ConfigManager
					.getStringConfig("search_cache_time");
		} catch (InvalidConfigException ex) {
			ex.printStackTrace();
			System.out.println("Config error: " + ex.getMessage());
		}
		return search_cache_time;
	}

	public String getVocabularyCacheTime() {
		String vocabulary_cache_time = "";
		try {
			vocabulary_cache_time = ConfigManager
					.getStringConfig("vocabulary_cache_time");
		} catch (InvalidConfigException ex) {
			ex.printStackTrace();
			System.out.println("Config error: " + ex.getMessage());
		}
		return vocabulary_cache_time;
	}

	public boolean isOverwriteEnabled() {
		boolean isOverwriteEnabled = false;
		try {
			isOverwriteEnabled = ConfigManager
					.getBooleanConfig("is_overwrite_enabled");
		} catch (InvalidConfigException ex) {
			ex.printStackTrace();
			System.out.println("Config error: " + ex.getMessage());
		}
		return isOverwriteEnabled;
	}

	public void writeConfig(String default_dir, String search_cache_time,
			String vocabulary_cache_time) {
		try {
			ConfigManager.writeConfig("default_dir", default_dir);
			ConfigManager.writeConfig("search_cache_time", search_cache_time);
			ConfigManager.writeConfig("vocabulary_cache_time",
					vocabulary_cache_time);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
